package com.swt.gap.service.impl;

import com.swt.gap.dao.ResultTemplateDao;
import com.swt.gap.model.entity.ResultTemplate;
import com.swt.gap.service.ResultTemplateService;
import com.swt.gap.util.UserLoginUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ResultTemplateServiceImpl implements ResultTemplateService {

    private final ResultTemplateDao resultTemplateDao;

    public ResultTemplateServiceImpl(ResultTemplateDao resultTemplateDao) {
        this.resultTemplateDao = resultTemplateDao;
    }

    @Override
    public Integer addResultTemplate(ResultTemplate record) {
        record.setCreatedTime(new Date());
        record.setCreatedBy(UserLoginUtils.getUserId());
        record.setDeleted(false);
        return resultTemplateDao.insertSelective(record);
    }

    @Override
    public ResultTemplate getResultTemplate(Integer templateId) {
        return resultTemplateDao.selectByPrimaryKey(templateId);
    }

    @Override
    public List<ResultTemplate> listAllResultTemplate() {
        return resultTemplateDao.selectAll();
    }

    @Override
    public Integer updateResultTemplate(ResultTemplate record) {

        return resultTemplateDao.updateByPrimaryKeySelective(record);
    }

    @Override
    public Integer deleteResultTemplate(Integer templateId) {
        return resultTemplateDao.deleteByPrimaryKey(templateId);
    }
}
